package org.bookstore.dao.impl;
import java.util.List;
import org.bookstore.dao.IUserDAO;
import org.bookstore.model.User;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class UserDAO extends HibernateDaoSupport implements IUserDAO{
	public void saveUser(User user){
		this.getHibernateTemplate().save(user);
	}
	public User validateUser(String username,String password){
		String str[]={username,password};
		List list=this.getHibernateTemplate().find("from User u where u.username=? and u.password=?",str);
		if(list.size()>0){
			User user=(User)list.get(0);
			return user;
		}else
			return null;
}
	public boolean exitUser(String username){
		List list=this.getHibernateTemplate().find("from User where username=?",username);
		if(list.size()>0)
			return true;
		else
			return false;
	}

}

